package com.weipai.springboot.module.controller;

import com.weipai.springboot.model.SpecialGoods;
import com.weipai.springboot.model.api.Response;
import com.weipai.springboot.module.service.SpecialGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 活动商品
 *
 * @author songmengqiang
 * @create 2018-08-28 18:23
 **/
@RestController
public class SpecialGoodsController {

    @Autowired
    private SpecialGoodsService specialGoodsService;

    //添加活动商品
    @PostMapping("/specialGoods/save")
    Response save(SpecialGoods specialGoods) {
        return specialGoodsService.save(specialGoods);
    }

    //修改活动商品
    @PostMapping("/specialGoods/update")
    Response updateSpecialGoods(SpecialGoods specialGoods) {
        return specialGoodsService.updateSpecialGoods(specialGoods);
    }

    //删除活动商品
    @GetMapping("/specialGoods/delete/{id}")
    Response deleteSpecialGoods(@PathVariable("id") Integer id) {
        return specialGoodsService.deleteSpecialGoods(id);
    }

    //批量删除活动商品
    @PostMapping("/specialGoods/batchDelete/{ids}")
    public Response batchDeleteSpecialGoods(@PathVariable("ids") Integer[] ids) {
        return specialGoodsService.batchDeleteSpecialGoods(ids);
    }

    //根据活动id查询活动商品分页列表
    @GetMapping("/specialGoods/list/{specialOfferId}/{page}/{size}/{draw}")
    Response listSpecialGoods(@PathVariable("specialOfferId")String specialOfferId,
                              @PathVariable("page")Integer page,
                              @PathVariable("size")Integer size,
                              @PathVariable("draw")String draw) {
        return specialGoodsService.listSpecialGoods(specialOfferId, page, size, draw);
    }
}
